<?php

class M_nguoidung extends CI_Model {

    function __construct() {
        parent::__construct();
        $this->load->database();
    }

    // lấy dữ liệu theo từng phần 
    function list_all($number, $offset) {
        $query = $this->db->get('nguoidung', $number, $offset);
        return $query->result_array();
    }

    // đếm tổng số record trong table book 
    function count_all() {
        return $this->db->count_all('nguoidung');
    }

    function getUser($MaNguoiDung) {
        $results = $this->db->get_where('nguoidung', array('MaNguoiDung' => $MaNguoiDung))->result_array();
        return $results;
    }

    function deleteUser($MaNguoiDung) {
        $this->db->delete('nguoidung', array('MaNguoiDung' => $MaNguoiDung));
    }

    function insertUser($data) {
        if ($this->db->insert('nguoidung', $data)) {
            return true;
        } else {
            return false;
        }
    }

    function updateUser($MaNguoiDung, $data) {
        $this->db->where('MaNguoiDung', $MaNguoiDung);
        $this->db->update('nguoidung', $data);
    }

}

?>